package com.movitech.mobile.cz.base.supplier.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.supplier.entity.SSupplierQualificationGrade;
import com.movitech.mobile.cz.base.supplier.service.SSupplierQualificationGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SSupplierQualificationGrade 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-02-28
 */
@RestController
@RequestMapping("/v1/sSupplierQualificationGrade")
@Api(value = "供方基本情况-资质等级基础操作接口", description = "供方基本情况-资质等级基础操作接口")
public class SSupplierQualificationGradeController {
    @Autowired
    @Qualifier("sSupplierQualificationGradeService")
    private SSupplierQualificationGradeService sSupplierQualificationGradeService;

    @GetMapping("/allList")
    @ApiOperation(
            value = "获取所有供方基本情况-资质等级接口",
            notes = "获取所有供方基本情况-资质等级接口",
            response = SSupplierQualificationGrade.class
    )
    public RestReturnResult list() {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SSupplierQualificationGrade> page = sSupplierQualificationGradeService.selectPage(new Page<SSupplierQualificationGrade>());
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @PostMapping("/searchList/{pageNumber}")
    @ApiOperation(
            value = "供方基本情况-资质等级列表查询接口",
            notes = "供方基本情况-资质等级列表查询接口",
            response = SSupplierQualificationGrade.class
    )
    public RestReturnResult searchList(@RequestBody SSupplierQualificationGrade sSupplierQualificationGrade,
                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SSupplierQualificationGrade> page = new Page<>();
        page.setCurrent(pageNumber);
        EntityWrapper wrapper = new EntityWrapper<>();
        wrapper.setEntity(sSupplierQualificationGrade);
        page = sSupplierQualificationGradeService.selectPage(page,wrapper);
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @GetMapping("/getSSupplierQualificationGrade/{id}")
    @ApiOperation(
            value = "供方基本情况-资质等级对象ID获取接口",
            notes = "供方基本情况-资质等级对对象ID获取接口",
            response = SSupplierQualificationGrade.class
    )
    public RestReturnResult addSSupplierQualificationGrade(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        SSupplierQualificationGrade sSupplierQualificationGrade = sSupplierQualificationGradeService.selectById(id);
        restReturnResult.setData(sSupplierQualificationGrade);
        return restReturnResult;
    }

    @PostMapping("/add")
    @ApiOperation(
            value = "供方基本情况-资质等级添加接口",
            notes = "供方基本情况-资质等级添加接口",
            response = SSupplierQualificationGrade.class
    )
    public RestReturnResult add(@RequestBody SSupplierQualificationGrade sSupplierQualificationGrade) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sSupplierQualificationGradeService.insert(sSupplierQualificationGrade);
        restReturnResult.setData(sSupplierQualificationGrade);
        return restReturnResult;
    }

    @PutMapping("/update")
    @ApiOperation(
            value = "供方基本情况-资质等级更新接口",
            notes = "供方基本情况-资质等级更新接口",
            response = SSupplierQualificationGrade.class
    )
    public RestReturnResult update(@RequestBody SSupplierQualificationGrade sSupplierQualificationGrade) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sSupplierQualificationGradeService.updateById(sSupplierQualificationGrade);
        restReturnResult.setData(sSupplierQualificationGrade);
        return restReturnResult;
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(
            value = "供方基本情况-资质等级通过ID删除接口",
            notes = "供方基本情况-资质等级通过ID删除接口",
            response = SSupplierQualificationGrade.class
    )
    public RestReturnResult update(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sSupplierQualificationGradeService.deleteById(id);
        return restReturnResult;
    }


}

